package com.manor.main.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.manor.common.utils.StaIntentUtil;
import com.manor.common.utils.StringUtil;
import com.manor.common.utils.WordUtil;
import com.manor.main.R;
import com.manor.main.bean.MianPersonalCentercBean;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class MianPersonalCentercAdapter extends BaseQuickAdapter<MianPersonalCentercBean, BaseViewHolder> {
    public MianPersonalCentercAdapter(int layoutResId, @Nullable List<MianPersonalCentercBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MianPersonalCentercBean item) {
        ImageView leftIcon = helper.getView(R.id.iv_leftIcon);

        Glide.with(getContext()).load(item.getLeftIcon()).into(leftIcon);
        String title = "";
        switch (item.getLeftText()) {
            case StaIntentUtil.ARISTOCRATIC_PRIVILEGE:
                title = WordUtil.getString(R.string.aristocratic_privilege);
                break;
            case StaIntentUtil.FLASH_TO_TALENT:
                title = WordUtil.getString(R.string.flash_to_talent);
                break;
            case StaIntentUtil.TWINKLE_SCHOOL:
                title = WordUtil.getString(R.string.twinkle_school);
                break;
            case StaIntentUtil.TASK_CENTER:
                title = WordUtil.getString(R.string.task_center);
                break;
            case StaIntentUtil.INVITE_FRIENDS:
                title = WordUtil.getString(R.string.invite_friends);
                break;
            case StaIntentUtil.VISITORS_RECORD:
                title = WordUtil.getString(R.string.visitors_record);
                break;
            case StaIntentUtil.RECOMMEND:
                title = WordUtil.getString(R.string.my_recommend);
                break;
            case StaIntentUtil.MY_EARNINGS:
                title = WordUtil.getString(R.string.my_earnings);
                break;
            case StaIntentUtil.QUICK_RECHARGE:
                title = WordUtil.getString(R.string.quick_recharge);
                break;
            case StaIntentUtil.PRIVACY_AGREEMENT:
                title = WordUtil.getString(R.string.privacy_agreement);
                break;
            case StaIntentUtil.REGISTRATION_AGREEMENT:
                title = WordUtil.getString(R.string.registration_agreement);
                break;
            case StaIntentUtil.SETTING_ACTIVITY:
                title = WordUtil.getString(R.string.set_up);
                break;
            case StaIntentUtil.GO_TO_AUTH:
                title = "扫脸认证";
                break;
            case StaIntentUtil.ONLINE_CUSTOMER:
                title = "在线客服";
                break;


        }
        helper.setText(R.id.tv_leftText, title);
        if (StringUtil.isNotEmpty(item.getStrNum())){
            helper.setText(R.id.tv_news,item.getStrNum());
            helper.setVisible(R.id.tv_news,true);
        }else {
            helper.setVisible(R.id.tv_news,false);
        }

    }

    public int getVPos(){
        if (StringUtil.isListEmpty(getData()))
            return -1;
        for (int i = 0; i < getData().size(); i++) {
            if (getData().get(i).getLeftText() == StaIntentUtil.VISITORS_RECORD){
                return i;
            }
        }
        return -1;
    }


}
